# The American Viewer: Political Consequences of Entertainment Media
# Eunji Kim and Shawn Patterson Jr 
# American Political Science Review 
# Replication File [Table 4]


table4 <- read.csv("table4_censored.csv")



pri12_romney <- felm(romney_share_primary12  ~ mccainshare08_new + 
                       log(population_04 +1) +
                       log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                       collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census  + religion_allP + 
                       log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                       STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                     data = table4, weights=table4$sum_CNTYTVHH) 

pri12_santorum <- felm(santorum_share_primary12~   mccainshare08_new + 
                         log(population_04 +1) +
                         log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                         collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                         log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                         STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                       data = table4, weights=table4$sum_CNTYTVHH) 

pri12_gingrich <- felm(gingrich_share_primary12  ~  mccainshare08_new + 
                         log(population_04 +1) +
                         log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                         collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                         log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                         STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                       data = table4, weights=table4$sum_CNTYTVHH) 

pri12_paul <- felm(paul_share_primary12  ~  mccainshare08_new + 
                     log(population_04 +1) +
                     log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                     collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                     log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                     STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                   data = table4, weights=table4$sum_CNTYTVHH) 



stargazer(pri12_romney, pri12_santorum, pri12_gingrich, pri12_paul, 
                                   star.cutoffs = c(0.1, .05,.01,.001),
                                   title="Placebo Test - Vote Shares of Republican Primary Candidates",
                                   dep.var.caption = "",
                                   dep.var.labels=c('Romney Share 12', 
                                                    'Santorum Share 12',
                                                    'Gingrich Share 12',
                                                    'Paul Share 12'),
                                   omit.stat=c("adj.rsq","LL","ser","f"),
                                   no.space=TRUE,
                                   omit = c("RTG_8PM_Nov_May", "population_04", "medianHHI_04", 
                                   "femaleP_04", "age65P_04", "whiteP_04", "blackP_04", 
                                   "collegeP_04", "foreignBP_04", "unemR_04", "samesex_census", 
                                   "religion_allP", "avg_outflow_movers", "avg_inflow_movers", 
                                  "pop_density.x", "STATE", "mccainshare08_new"),
                                    star.char = c("+", "*", "**", "***"), 
                                   notes = c("*p<0.1, * p<0.05; ** p<0.01; *** p<0.001"), 
                                   notes.append = F,
                                   notes.align="l",
                                   digits=3,
                                  type ="text",
                                   align = TRUE)
